package com.ruoyi.hkCamera.config;

import cn.hutool.core.util.StrUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 录像机参数配置
 */
@Data
@Component
@ConfigurationProperties(prefix = "vcr")
public class VcrParamsConfig {

    /**
     * 设备ip地址
     */
    private String ip;

    /**
     * 设备端口号
     */
    private String port;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 视频时长偏移秒数
     */
    private int offsetStart = -5;
    private int offsetStop = 5;

    /**
     * 通道号
     */
    private String videoChannel;

    public int getDwChannel(String laneNo) {
        List<String> channelList = StrUtil.split(this.videoChannel, ",");
        for (String channel : channelList) {
            String[] split = channel.split("-");
            if (split[0].equals(laneNo)) {
                return Integer.parseInt(split[1]);
            }
        }
        return 0;
    }

}
